package org.jctc.els.common.config;

import cn.hutool.core.lang.Snowflake;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * snowflake 配置
 *
 * @author Lianxw
 * @since 2022/3/25
 */
@Configuration
public class IdConfig {

	@Value("${snowflake.datacenter-id:1}")
	private long datacenterId;
	@Value("${snowflake.worker-id:1}")
	private long workerId;

	@Bean
	public Snowflake snowflake() {
		return new Snowflake(workerId, datacenterId);
	}

}
